const { replaceInFileSync } = require("replace-in-file");

function replaceContextRoot(url) {
  try {
    const results = replaceInFileSync({
      files: "./public/activiti/editor-app/app-cfg.js",
      from: /"http:\/\/.*\/service"/,
      to: `"${url}"`,
      countMatches: true,
    });
    console.log("activiti replacement results:", results);
  } catch (e) {
    console.log(e);
  }
}

module.exports = {
  enable: true,
  development: `http://192.168.3.123/sxpms-admin/dev/api/service`,
  dev: `http://192.168.3.123/sxpms-admin/dev/api/service`,
  qa: `http://192.168.3.133/sxpms-admin/qa/api/service`,
  uat: `http://uat.jzxk.net:18080/sxpms-admin/uat/api/service`,
  production: `http://36.140.17.232:8888/sxpms-admin/api/service`,
  replaceContextRoot,
};
